<?php
/**
* Seyret Featured Slider Module For Joomla
* @ All rights reserved
* @ Released under GPLv2.0
* @ version 1.2.1
* @ August 2009 by www.rumahbelanja.com
* @ Last updated on Nov 2009
**/	
// no direct access
defined('_JEXEC') or die('Restricted access');

class modSeyretFeaturedSliderHelper
{

	/**
	 * Method to get the lists
	 *
	 * @access public
	 * @return array
	 */
	function getList(&$params)
	{
		global $mainframe;

		$db			=& JFactory::getDBO();

		$tipe  = $params->get( 'tipe', '1' );
		$lists = array();
		$query = 'SELECT * FROM #__seyret_items where featured="1" ';
		
		$vidscreenshot  = $params->get( 'vidscreenshot', '0' );
		$screenshot0 = $params->get( 'screenshot0' );
		$screenshot1 = $params->get( 'screenshot1' );
		$screenshot2 = $params->get( 'screenshot2' );
		$screenshot3 = $params->get( 'screenshot3' );

		if($tipe==1){
			$query .= 'ORDER BY rand() LIMIT 0,4';
		}
		else{
			$query .= 'ORDER BY addeddate DESC LIMIT 0,4';	
		}
		$db->setQuery($query);
		$rows = $db->loadObjectList();
		$row1 = $rows[0];
		$type1= $rows[0]->videoservertype;
		if ($type1!="localfile"){
			$videofile1 = "http://www.youtube.com/v/" . $rows[0]->videoservercode;
		}else{
			$videofile1 = $rows[0]->videoservercode;
		}
		$lists[0]->videofile = $videofile1;
		$lists[0]->picturelink = $row1->picturelink;
		$row2 = $rows[1];
		$type2= $rows[1]->videoservertype;
		if ($type2!="localfile"){
			$videofile2 = "http://www.youtube.com/v/" . $rows[1]->videoservercode;
		}else{
			$videofile2 = $rows[1]->videoservercode;
		}
		$lists[1]->videofile = $videofile2;
		$lists[1]->picturelink = $row2->picturelink;
		$row3 = $rows[2];
		$type3= $rows[2]->videoservertype;
		if ($type3!="localfile"){
			$videofile3 = "http://www.youtube.com/v/" . $rows[2]->videoservercode;
		}else{
			$videofile3 = $rows[2]->videoservercode;
		}
		$lists[2]->videofile = $videofile3;
		$lists[2]->picturelink = $row3->picturelink;
		$row4 = $rows[3];
		$type4= $rows[3]->videoservertype;
		if ($type4!="localfile"){
			$videofile4 = "http://www.youtube.com/v/" . $rows[3]->videoservercode;
		}else{
			$videofile4 = $rows[3]->videoservercode;
		}		
		$lists[3]->videofile = $videofile4;
		$lists[3]->picturelink = $row4->picturelink;
		
		//The Screeshoot 
		if($vidscreenshot==0){
			$lists[0]->sclink = $row1->picturelink;
			$lists[1]->sclink = $row2->picturelink;
			$lists[2]->sclink = $row3->picturelink;
			$lists[3]->sclink = $row4->picturelink;
		} else{
			$lists[0]->sclink 	= $screenshot0;
			$lists[1]->sclink 	= $screenshot1;
			$lists[2]->sclink 	= $screenshot2;
			$lists[3]->sclink 	= $screenshot3;
		}
		return $lists;
	}
}